/**
 * Created by jaliu on 2015/2/28.
 */


module.exports = function (app) {
    var lottery = require('../../controllers/backoffice/backOffice-lottery-controller');
    logger.debug("load the backoffice lottery-route module....");

    //rest路由

    //检查是否有资格抽奖，返回（yes/no, 以及当前参与人数）：参数userObjId+lotteryObjId
    //result:{
    //    valid: boolean
    //    joinedUser:100
    //}

    //获取下一次抽奖时间定义 , 参数 - lotteryObjId
    //result{
    //    --lotteryDrawType:  weekly - 每周，monthly - 每月，specificDate -一次性抽奖
    //    --WeekDay : //1-周一，2-周二，3-周三，4-周四，5-周五，6-周六，7-周日
    //    --WeekDayTime: 00:00:00     //时间
    //    --monthDay: //1,2,3,4,5,6,7....  //一月中的那一天
    //    --monthDayTime: 00:00:00   //时间
    //    --specificDateTime:   //具体某个日期和时间
    //}

    //获取中奖人员清单： 参数 -lotteryObjId
    // [{
    //    头像URL
    //    用户nickName,
    //    门牌号
    //    抽奖日期
    //}]

    //获取中奖号码：参数userObjId+lotteryObjId
    //
    //result:{
    // ticketValue:'2342432'
    // }

    //
    app.post('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/addWeekLottery', lottery.addWeekLottery);
    //app.post('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/updateLottery/:RESTServiceObjId', lottery.updateLottery);
    //app.delete('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/listLottery/:lotteryObjId', lottery.deleteLottery);
    // ...

    app.get('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/validateUserForLottery/:token/:lotteryId', lottery.validateUserForLottery);
    app.post('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/generateLotteryTicketForUser/:token/:lotteryId', lottery.generateLotteryTicketForUser);
    app.get('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/getLuckyUserList/:lotteryId', lottery.getLuckyUserList);
    app.get('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/getLcLuckyUserList/:week/:lotteryId', lottery.getLcLuckyUserList);
    app.get('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/lotteryUser/:lotteryId/:weekId/:rank', lottery.lotteryUser);
    app.get('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/getLuckyUser/:lotteryId/:weekId', lottery.getLuckyUser);
    app.get('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/openLottery/:lotteryId/:weekId', lottery.openLottery);
    app.get('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/getLotteryActivity/:communityId', lottery.getLotteryActivity);

    app.get('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/getUserInfo/:token/:activityId', lottery.getUserInfo);
    app.post('/rest/' + RESTFullServiceVersion + '/backoffice/lottery/doRegisterActivity/:token/:activityId', lottery.doRegisterActivity);
};
